using Coding4Fun.Phone.Controls.Primitives;
using Coding4Fun.Phone.Controls.Toolkit.Primitives;
using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
namespace Coding4Fun.Phone.Controls.Toolkit
{
	public class TimeSpanPickerPage : TimeSpanPickerBasePage
	{
		internal VisualStateGroup VisibilityStates;
		internal VisualState Open;
		internal VisualState Closed;
		internal PlaneProjection PlaneProjection;
		internal Rectangle SystemTrayPlaceholder;
		internal LoopingSelector PrimarySelector;
		internal LoopingSelector SecondarySelector;
		internal LoopingSelector TertiarySelector;
		private bool _contentLoaded;
		public TimeSpanPickerPage()
		{
			this.InitializeComponent();
		}
		public override void InitDataSource()
		{
			int seconds = base.IncrementStep.get_Seconds();
			int int_ = (base.Max >= TimeSpan.FromMinutes(1.0)) ? 60 : Math.Min(base.Max.get_Seconds() + seconds, 60);
			this.TertiarySelector.DataSource = new SecondTimeSpanDataSource(int_, seconds);
			int num = (base.IncrementStep > TimeSpan.FromMinutes(1.0)) ? base.IncrementStep.get_Minutes() : 1;
			int int_2 = (base.Max >= TimeSpan.FromHours(1.0)) ? 60 : Math.Min(base.Max.get_Minutes() + num, 60);
			this.SecondarySelector.DataSource = new MinuteTimeSpanDataSource(int_2, num);
			int num2 = (base.IncrementStep > TimeSpan.FromHours(1.0)) ? base.IncrementStep.get_Hours() : 1;
			int int_3 = (base.Max >= TimeSpan.FromHours(24.0)) ? 24 : (base.Max.get_Hours() + num2);
			this.PrimarySelector.DataSource = new HourTimeSpanDataSource(int_3, num2);
			base.InitializeValuePickerPage(this.PrimarySelector, this.SecondarySelector, this.TertiarySelector);
		}
		protected override IEnumerable<LoopingSelector> GetSelectorsOrderedByCulturePattern()
		{
			IEnumerable<LoopingSelector> selectorsOrderedByCulturePattern = ValuePickerBasePage<TimeSpan>.GetSelectorsOrderedByCulturePattern(CultureInfo.get_CurrentCulture().get_DateTimeFormat().get_LongTimePattern().ToUpperInvariant(), new char[]
			{
				'H',
				'M',
				'S'
			}, new LoopingSelector[]
			{
				this.PrimarySelector,
				this.SecondarySelector,
				this.TertiarySelector
			});
			IEnumerable<LoopingSelector> arg_6C_0 = selectorsOrderedByCulturePattern;
			if (TimeSpanPickerPage.CS$<>9__CachedAnonymousMethodDelegate1 == null)
			{
				TimeSpanPickerPage.CS$<>9__CachedAnonymousMethodDelegate1 = new Func<LoopingSelector, bool>(TimeSpanPickerPage.smethod_4);
			}
			return Enumerable.Where<LoopingSelector>(arg_6C_0, TimeSpanPickerPage.CS$<>9__CachedAnonymousMethodDelegate1);
		}
		protected override void OnOrientationChanged(OrientationChangedEventArgs orientationChangedEventArgs_0)
		{
			if (orientationChangedEventArgs_0 == null)
			{
				throw new ArgumentNullException("e");
			}
			base.OnOrientationChanged(orientationChangedEventArgs_0);
			this.SystemTrayPlaceholder.set_Visibility(((1 & orientationChangedEventArgs_0.get_Orientation()) != null) ? 0 : 1);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/Coding4Fun.Phone.Controls.Toolkit;component/TimeSpanPicker/TimeSpanPickerPage.xaml", 2));
			this.VisibilityStates = (VisualStateGroup)base.FindName("VisibilityStates");
			this.Open = (VisualState)base.FindName("Open");
			this.Closed = (VisualState)base.FindName("Closed");
			this.PlaneProjection = (PlaneProjection)base.FindName("PlaneProjection");
			this.SystemTrayPlaceholder = (Rectangle)base.FindName("SystemTrayPlaceholder");
			this.PrimarySelector = (LoopingSelector)base.FindName("PrimarySelector");
			this.SecondarySelector = (LoopingSelector)base.FindName("SecondarySelector");
			this.TertiarySelector = (LoopingSelector)base.FindName("TertiarySelector");
		}
		[CompilerGenerated]
		private static bool smethod_4(LoopingSelector loopingSelector_0)
		{
			return !loopingSelector_0.DataSource.IsEmpty;
		}
	}
}
